import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GImageBitmap } from "../../../../../com/mui/controls/GImageBitmap";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { FontUtil } from "../../../../common/font/FontUtil";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { ArenaCrossGroupIdData } from "../arenaCrossData/ArenaCrossGroupIdData";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
//class ArenaCrossGroupCellRenderer
    
    export  class ArenaCrossGroupCellRenderer extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._bmpBg = new Object /* flash.display.Bitmap */();
            this.addChild(this._bmpBg);
            this._bmpStar = ObjCreate.createBitmap(ImagesConst.ChatGuildMember_star, 13, 13, this);
            this._bmpStar.visible = false;
            this._bmpTxtBg = new GImageBitmap("ArenaCrossGroupItemNumBg.png", 36, 10);
            this.addChild(this._bmpTxtBg);
            var loc1=GlobalStyle.textFormatGreen;
            loc1.size = 18;
            loc1.font = FontUtil.EmbedNumberName;
            this._tfGroupNum = ObjCreate.createEmbedTextFiled("", 60, 13, 30, 20, this, loc1);
            LoaderHelp.addResCallBack(ResFileConst.ArenaCrossGroupBg, this.bgCompl);
            return;
        }

        /* internal  */bgCompl(): void
        {
            this._isBgCompl = true;
            this.updateView();
            return;
        }

        public /* override */ set selected(arg1: Boolean)
        {
            super.selected = arg1;
            this.updateView();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            if (typeof arg1 === "arenacrossgroupiddata") 
            {
                this._groupIdData = arg1 as ArenaCrossGroupIdData;
                this.updateView();
            }
            return;
        }

        protected updateView(): void
        {
            var loc1=false;
            if (this._groupIdData && this._isBgCompl) 
            {
                loc1 = this._groupIdData.groupId == this._groupIdData.myGroupId;
                if (loc1) 
                {
                    this._bmpStar.visible = true;
                }
                else 
                {
                    this._bmpStar.visible = false;
                }
                this._tfGroupNum.text = this._groupIdData.groupId.toString();
                if (this.selected) 
                {
                    this._bmpBg.bitmapData = GlobalClass.getBitmapData(ImagesConst.ArenaCrossGroupSelected);
                }
                else if (loc1) 
                {
                    this._bmpBg.bitmapData = GlobalClass.getBitmapData(ImagesConst.ArenaCrossGroupMine);
                }
                else 
                {
                    this._bmpBg.bitmapData = GlobalClass.getBitmapData(ImagesConst.ArenaCrossGroupNormal);
                }
            }
            return;
        }

        /* internal */ /* var */_bmpBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_bmpStar: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_bmpTxtBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tfGroupNum: Object /* flash.text.TextField */;

        /* internal */ /* var */_isBgCompl: Boolean=false;

        /* internal */ /* var */_groupIdData: ArenaCrossGroupIdData;
    }
